app.controller('loginCtrl',['$scope','$location','$http',function($scope,$location,$http){

    $('.loginUser').focus(function(e){
        $(this).parent().css('background-color','transparent')
    });
    $('.loginUser').blur(function(){
        $(this).parent().css('background-color','white');
    });

        $scope.login = function () {
            /*            if ($scope.user && $scope.user.user && $scope.user.password) { //如果用户和用户名及密码都是正确的

                            $http.post('/system/login!gogonew.action', $scope.user.user && $scope.user.password, config).then(successCallback, errorCallback);
            */
            if ($scope.user!=undefined&& $scope.password!=undefined){
                //console.log($scope.user);
                mui.showLoading('正在加载','div');

            $http({
                    method : 'GET',
                    url : mainUrl+'/system/login!gogoNew.action?nicaicai='+$scope.user+'&woshishui='+$scope.password
                }).then(function(data, status, headers, config) {
                    if(data.data.success == true){
                        //console.log(data);
                        var localStorage = window.localStorage;
                        localStorage.setItem('token',data.data.items[0].token);
                        localStorage.setItem('controlFlag',data.data.items[0].controlFlag);
                       /* localStorage.userId = data.userId;

                        localStorage.username = data.username;

                        localStorage.telephone = data.phone;*/
                        console.log(data);
                        // localStorage.token = data.data.items[0].token;
                        localStorage.setItem('userData',JSON.stringify(data.data.items[0]));
                        if(data.data.items[0].company == "GF")
                        {
                            localStorage.setItem('morengongsi',"股份公司");
                        }
                        if(data.data.items[0].company == "JT")
                        {
                            localStorage.setItem('morengongsi',"京唐公司");
                        }
                        if(data.data.items[0].company== "SQ")
                        {
                            localStorage.setItem('morengongsi',"秦皇公司");
                        }
                        if(data.data.items[0].company== "KY")
                        {
                            localStorage.setItem('morengongsi',"矿业公司");
                        }
                        if(data.data.items[0].company== "CG")
                        {
                            localStorage.setItem('morengongsi',"长钢公司");
                        }
                        if(data.data.items[0].company== "SG")
                        {
                            localStorage.setItem('morengongsi',"水钢公司");
                        }
                        if(data.data.items[0].company== "GG")
                        {
                            localStorage.setItem('morengongsi',"贵钢公司");
                        }
                        if(data.data.items[0].company== "TG")
                        {
                            localStorage.setItem('morengongsi',"通钢公司");
                        }
                        if(data.data.items[0].company== "YG")
                        {
                            localStorage.setItem('morengongsi',"伊钢公司");
                        }
                        if(data.data.items[0].company== "HJ")
                        {
                            localStorage.setItem('morengongsi',"环境公司");
                        }
                        if(data.data.items[0].company== "SY")
                        {
                            localStorage.setItem('morengongsi',"实业公司");
                        }
                        if(data.data.items[0].company== "ZX")
                        {
                            localStorage.setItem('morengongsi',"首自信");
                        }
                        if(data.data.items[0].company== "JD")
                        {
                            localStorage.setItem('morengongsi',"机电公司");
                        }
                        if(data.data.items[0].company== "KT")
                        {
                            localStorage.setItem('morengongsi',"矿投公司");
                        }
                        if(data.data.items[0].company== "LS")
                        {
                            localStorage.setItem('morengongsi',"鲁家山矿");
                        }
                        if(data.data.items[0].company== "JX")
                        {
                            localStorage.setItem('morengongsi',"京西重工");
                        }
                        if(data.data.items[0].company== "GJ")
                        {
                            localStorage.setItem('morengongsi',"国际工程");
                        }
                        if(data.data.items[0].company== "CY")
                        {
                            localStorage.setItem('morengongsi',"首钢城运");
                        }
                        if(data.data.items[0].company== "KG")
                        {
                            localStorage.setItem('morengongsi',"首钢控股");
                        }
                        if(data.data.items[0].company== "YQ")
                        {
                            localStorage.setItem('morengongsi',"氧气厂");
                        }
                        if(data.data.items[0].company== "BY")
                        {
                            localStorage.setItem('morengongsi',"北冶材料");
                        }
                        if(data.data.items[0].company== "TA")
                        {
                            localStorage.setItem('morengongsi',"首钢吉泰安");
                        }
                        if(data.data.items[0].company == "ZS")
                        {
                            localStorage.setItem('morengongsi',"中首公司");
                        }
                        if(data.data.items[0].company == "JS")
                        {
                            localStorage.setItem('morengongsi',"首钢建设");
                        }
                        if(data.data.items[0].company == "DC")
                        {
                            localStorage.setItem('morengongsi',"房地产公司");
                        }
                        if(data.data.items[0].company == "TS")
                        {
                            localStorage.setItem('morengongsi',"特钢公司");
                        }
                        if(data.data.items[0].company == "DK")
                        {
                            localStorage.setItem('morengongsi',"地勘院");
                        }
                        if(data.data.items[0].company == "TY")
                        {
                            localStorage.setItem('morengongsi',"体育文化");
                        }
                        if(data.data.items[0].company == "YF")
                        {
                            localStorage.setItem('morengongsi',"园区服务公司");
                        }
                        if(data.data.items[0].company == "YL")
                        {
                            localStorage.setItem('morengongsi',"园区管理部");
                        }
                        if(data.data.items[0].company == "JY")
                        {
                            localStorage.setItem('morengongsi',"技研院");
                        }
                        if(data.data.items[0].company == "WH")
                        {
                            localStorage.setItem('morengongsi',"首钢文化");
                        }
                        if(data.data.items[0].company == "WL")
                        {
                            localStorage.setItem('morengongsi',"首运物流");
                        }
                        if(data.data.items[0].company == "YY")
                        {
                            localStorage.setItem('morengongsi',"首钢医院");
                        }
                        if(data.data.items[0].company == "TH")
                        {
                            localStorage.setItem('morengongsi',"首钢铁合金");
                        }
                        if(data.data.items[0].company == "RC")
                        {
                            localStorage.setItem('morengongsi',"人才开发院");
                        }
                        if(data.data.items[0].company == "YK")
                        {
                            localStorage.setItem('morengongsi',"首钢建设投资");
                        }
                        $location.path('/shouye');
                        mui.hideLoading();
                        //location.reload();
                    }else{
                        console.log(data);
                        mui.toast(data.data.message);
                        mui.hideLoading();
                    }

                },function(data, status, headers, config) {
                    mui.toast('网络连接有问题....')
                mui.hideLoading();
                });
             /*   ($scope.user, function (data) {
                    localStorage.userId = data.userId;

                    localStorage.username = data.username;

                    localStorage.telephone = data.phone;
                    localStorage.token = data.id;
                    localStorage.avator = data.avator;
                    $scope.$emit('login', data.id);
                    $location.path('/')
                        //登录成功跳转页面
                })*/
            }
        else{
                mui.toast('请输入用户名或密码')
            }}
            }]);